/*访问表格数据的通用方法，原理是通过当前文档的路径动态构建对应的访问链接，
适用于访问设备数据表，异常数据表，人员名单的数据*/
$.ajax({
    url: `/api/excel-data/${ location.search }`,
    type: "GET",
    dataType: "json",
    success: function(data) {
        var $tbody = $("tbody");
        var strHtml = "";
        data.sort(function x(a, b){return a[0] - b[0]});
        function x(value, index, array){
            strHtml += "<tr><td>" + (value[0]) + "</td>";
            for (let i = 1; i < value.length - 1; i++) {
                strHtml += "<td>" + value[i] + "</td>";
            }
            strHtml += "<td>" + value[value.length - 1] + "</td></tr>";
        }
        data.forEach(x);
        $tbody.html(strHtml);
        if (window.staffpermission.indexOf("2") != -1){
            window.m = new Map();
            $.ajax({
                url: `/api/excel-data/?q=staff`,
                type: "GET",
                dataType: "json",
                success: function(data) {
                    for (const i of data){
                        window.m.set(i[0], i[1]);
                    }
                }
            })
        }
    }
})








